﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyTruongHoc_App
{
    public partial class Main : Form
    {
        public Main()
        {
            InitializeComponent();
            this.Text = PConst.APP_NAME;
            Main_Resize(this, new EventArgs());

            //this.MDI
            lgLogin.LogIn += new QuanLyTruongHoc_App.MyControls.LogInControl.EventUpdate(lgLogin_LogIn);
            mn_HeThong_DangXuat.Enabled = false;

            lgLogin.Visible = false;
        }

        private void Main_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
        }

        private void Main_Resize(object sender, EventArgs e)
        {
            lgLogin.Top = (this.Height - mnMainMenu.Height - lgLogin.Height) / 2;
            lgLogin.Left = (this.Width - lgLogin.Width) / 2;
        }

        private void lgLogin_LogIn(object sender)
        {
            if (PublicLib.checkLogin(lgLogin.Username, lgLogin.Password))
            {
                doLogin();
            }
            else
            {
                MessageBox.Show(MSG.MSG_LOGIN_FAILE);
                lgLogin.Focus();
            }
        }

        private void doLogin()
        {
            PConst.CURR_USER = lgLogin.Username;
            lgLogin.Visible = false;
            mn_HeThong_DangXuat.Enabled = true;
        }

        private void doLogOut()
        {
            PConst.CURR_USER = "";
            lgLogin.Visible = true;
            mn_HeThong_DangXuat.Enabled = false;
        }

        private void mn_HeThong_DangXuat_Click(object sender, EventArgs e)
        {
            doLogOut();
        }

        private void mn_HeThong_Thoat_Click(object sender, EventArgs e)
        {
            doLogOut();
            Application.Exit();
        }

        private void mn_QuanLy_GiaoVien_DanhSach_Click(object sender, EventArgs e)
        {
            QuanLy.QuanLyGiaoVien frm_QLGV = new QuanLyTruongHoc_App.QuanLy.QuanLyGiaoVien();
            frm_QLGV.MdiParent = this;
            frm_QLGV.Show();
        }

        private void mn_QuanLy_GiaoVien_Them_Click(object sender, EventArgs e)
        {
            AddEditGiaoVien frm_AddGiaoVien = new AddEditGiaoVien();
            frm_AddGiaoVien.Show();
        }

        private void mn_QuanLy_GiaoVien_CanBo_Click(object sender, EventArgs e)
        {
            QLHinhThucCanBo frm_QLHinhThucCB = new QLHinhThucCanBo();
            frm_QLHinhThucCB.Show();
        }

        private void mn_QuanLy_GiaoVien_DanhGia_Click(object sender, EventArgs e)
        {
            QLDanhGia frm_QLDanhGia = new QLDanhGia();
            frm_QLDanhGia.Show();
        }

        private void mc_QuanLy_GiaoVien_HopDong_Click(object sender, EventArgs e)
        {
            QLHopDong frm_QLHopDong = new QLHopDong();
            frm_QLHopDong.Show();
        }

        private void mn_NhaTruong_LopHoc_DanhSach_Click(object sender, EventArgs e)
        {
            QLLopHoc frm_QLLopHoc = new QLLopHoc();
            frm_QLLopHoc.Show();
        }

        private void hìnhThứcLớpHọcToolStripMenuItem_Click(object sender, EventArgs e)
        {
            QLKieuLop frm_KieuLop = new QLKieuLop();
            frm_KieuLop.Show();
        }

        private void mn_NhaTruong_CaHoc_Click(object sender, EventArgs e)
        {
            QLCaHoc frm_CaHoc = new QLCaHoc();
            frm_CaHoc.Show();
        }

        private void mn_NhaTruong_KhoiLop_Click(object sender, EventArgs e)
        {
            QLKhoiLop frm_Khoi = new QLKhoiLop();
            frm_Khoi.Show();
        }

        private void mn_NhaTruong_PhongHoc_Click(object sender, EventArgs e)
        {
            QLPhongHoc frm_PhongHoc = new QLPhongHoc();
            frm_PhongHoc.Show();
        }

        private void mn_NhaTruong_LopHoc_Them_Click(object sender, EventArgs e)
        {
            AddEditLopHoc frm_AddLopHoc = new AddEditLopHoc();
            frm_AddLopHoc.Show();
        }

        private void mn_MonHoc_Them_Click(object sender, EventArgs e)
        {
            AddEditMonHoc frm_AddMonHoc = new AddEditMonHoc();
            frm_AddMonHoc.Show();
        }

        private void mn_MonHoc_HinhThuc_Click(object sender, EventArgs e)
        {
            QLHTMonHoc frm_HTMonHoc = new QLHTMonHoc();
            frm_HTMonHoc.Show();
        }

        private void mn_MonHoc_DanhSach_Click(object sender, EventArgs e)
        {
            QLMonHoc frm_QLMonHoc = new QLMonHoc();
            frm_QLMonHoc.Show();
        }

        private void mn_MonHoc_QLDiem_Click(object sender, EventArgs e)
        {
            QLLoaiDiem frm_LoaiDiem = new QLLoaiDiem();
            frm_LoaiDiem.MdiParent = this;
            frm_LoaiDiem.Show();
        }

        private void mn_NhaTruong_NhapTruong_Click(object sender, EventArgs e)
        {
            QLNhapTruong frm_NhapTruong = new QLNhapTruong();
            frm_NhapTruong.MdiParent = this;
            frm_NhapTruong.Show();
        }

        private void mn_HocSinh_ThemMoi_Click(object sender, EventArgs e)
        {
            AddEditHocSinh frm_ThemHS = new AddEditHocSinh();
            frm_ThemHS.MdiParent = this;
            frm_ThemHS.Show();
        }

        private void mn_HocSinh_DanhSach_Click(object sender, EventArgs e)
        {
            QLHocSinh frm_HocSinh = new QLHocSinh();
            frm_HocSinh.MdiParent = this;
            frm_HocSinh.Show();
            //frm_HocSinh.WindowState = FormWindowState.Maximized;
        }
    }
}
